import cv2
import numpy as np
# import copy
# first ask, what does today's OS do?
# just plotting?
def filterX(a,b):
    if a is not None:
        lower_red=np.array([*b])
        mask=cv2.inRange(a,lower_red,lower_red)
        return cv2.bitwise_and(a,a,mask=mask)
    else:
        return None
d="Screenshot_2020-06-29-20-01-36-366_net.csdn.csdnplus.jpg"
# draw something onto the screenshot?
# yes.
# we're using histograms.
# no overlaps?
d=cv2.imread(d)
print(d,d.shape,type(d))
x,y,z=d.shape
# how to form sparse code?
# guys ready to get rid of everything.
print(dir(d))
# scanning through the whole scenario.
# if you can only classify those things.
f={(x0,y0):d[x0,y0] for x0 in range(x) for y0 in range(y)}
print("hello world")
f0=[tuple(d[z0].tolist()) for z0 in f]
print("hello world")
f1=set(f0)
print("hello world")
f2=np.array(f0)
for z0 in f1:
    print(np.count_nonzero(f2==z0))
    # this is way too slow.
# this will not gonna work out that fast.
# whatever you like. it is all not good at all.
# get the range.
# still slow as hell.
# not really fast.
# all I want is the fucking histogram. what is the fucking problem?
# do I need to get rid of it? pixelize it?
# yes you should.
# but what about the text?
# you can also do the thing. pixelize.
# f2={z0:f0.count(z0) for z0 in f1}
# # too damn slow.
# this is not going to work.
# must group these things together.
# # just get the heck of it?
# print("hello world")
# choose few selected colors and be good.
# # get it changed.
# # not counting.
# # do the calculation?
# # this is 3-dimensional.
# # # what the heck is going on?
# # # why so goddamn slow?
# # # no natural counter available?
# for z0 in f1:
#     print(z0)
#     sf=filterX(d,z0)
#     cv2.imshow(str(z0),sf)
#     cv2.waitKey(0)
#     # well, classification needed.
    # and consider to inverse the color.